<!-- 切换详情页 -->
<template>
  <div class="change-list">
    <!-- list-wrap-vertical
      list-wrap -->
    <div :class="listChangeFlag ? 'list-wrap' : 'list-wrap-vertical'">
      <ul>
        <li
          v-for="goodslistData in goodslistDatas"
          :key="goodslistData.id"
          @click="toGoodsDetails"
        >
          <img :src="goodslistData.goods_thumb" alt="" />
          <!-- 商品内容 -->
          <div class="goods-content">
            <div class="title">{{ goodslistData.title }}</div>
            <!-- 流通价格 -->
            <div class="currency-price">
              <span>
                <em>¥</em>
                <!-- 整数部分 -->
                <span>{{ goodslistData.shop_price | setInt }}</span>
                <!-- 小数部分 -->
                <em>{{ goodslistData.shop_price | setFloat }}</em>
              </span>
            </div>
            <!-- 自营 -->
            <div class="self">
              <em>自营</em>
            </div>
            <div class="buy-info">
              <span>3人已购买</span>
              <div class="add_cart">
                <i class="iconfont icon-gouwuche"></i>
              </div>
            </div>
          </div>
        </li>
      </ul>
    </div>
  </div>
</template>

<script>
//这里可以导入其他文件（比如：组件，工具js，第三方插件js，json文件，图片文件等等）
//例如：import 《组件名称》 from '《组件路径》';

export default {
  //import引入的组件需要注入到对象中才能使用
  components: {},
  data() {
    //这里存放数据
    return {};
  },
  //计算属性 类似于data概念
  computed: {},
  //监控data中的数据变化
  watch: {},
  //方法集合
  methods: {
    toGoodsDetails() {
      this.$router.push("/goodsdetails");
    },
  },
  props: ["goodslistDatas", "listChangeFlag"],
};
</script>
<style lang="less">
.change-list {
  .list-wrap {
    ul {
      display: flex;
      flex-wrap: wrap;
      margin-top: 0.5rem;
      li {
        width: calc(50% - 1rem);
        height: 31.3rem;
        margin: 0.5rem;
        border-radius: 1rem;
        background-color: #fff;
        img {
          width: 17.8rem;
          height: 17.8rem;
          border-radius: 1rem;
        }
        .goods-content {
          padding: 0 1rem;
          .title {
            width: 90%;
            margin: 5%;
            height: 4rem;
            line-height: 2rem;
            font-size: 1.2rem;
            // 多行文本省略号
            display: -webkit-box;
            -webkit-box-orient: vertical;
            -webkit-line-clamp: 2;
            overflow: hidden;
          }
          .currency-price {
            color: rgb(226, 44, 44);
            font-weight: 700;
            padding-left: 0.5rem;
            span {
              font-size: 1.5rem;
              em {
                font-size: 1rem;
              }
            }
          }
          .self {
            margin: 1rem 0;
            em {
              padding: 0 0.5rem;
              background-color: #f92028;
              color: #fff;
              height: 1.6rem;
              border-radius: 0.2rem;
            }
          }
          .buy-info {
            display: flex;
            justify-content: space-between;
            span {
              color: #666;
            }
            .add_cart {
              color: #f92028;
            }
          }
        }
      }
    }
  }
  .list-wrap-vertical {
    ul {
      display: flex;
      flex-wrap: wrap;
      margin-top: 0.5rem;
      li {
        width: calc(100% - 1rem - 2rem);
        height: 13.3rem;
        margin: 0.5rem;
        border-radius: 1rem;
        background-color: #fff;
        display: flex;
        padding: 1rem;
        img {
          width: 9rem;
          height: 9rem;
          box-sizing: border-box;
          border: 0.1rem solid #ccc;
          margin-top: 0.5rem;
        }
        .goods-content {
          padding: 0 1rem;
          .title {
            width: 90%;
            margin: 5%;
            height: 4rem;
            line-height: 2rem;
            font-size: 1.2rem;
            // 多行文本省略号
            display: -webkit-box;
            -webkit-box-orient: vertical;
            -webkit-line-clamp: 2;
            overflow: hidden;
          }
          .currency-price {
            color: rgb(226, 44, 44);
            font-weight: 700;
            padding-left: 0.5rem;
            span {
              font-size: 1.5rem;
              em {
                font-size: 1rem;
              }
            }
          }
          .self {
            margin: 1rem 0;
            em {
              padding: 0 0.5rem;
              background-color: #f92028;
              color: #fff;
              height: 1.6rem;
              border-radius: 0.2rem;
            }
          }
          .buy-info {
            display: flex;
            justify-content: space-between;
            span {
              color: #666;
            }
            .add_cart {
              color: #f92028;
            }
          }
        }
      }
    }
  }
}
</style>